#!/usr/bin/
# -*- coding: UTF-8 -*-
import os

from selenium import webdriver

from common.global_logger import logger
# pro变量 是一个字典
from common.global_property import pro


def start_chrome_driver():
    logger.info("打开chrome浏览器")
    chrome_driver_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, "config", "chromedriver.exe"))
    driver = webdriver.Chrome(executable_path=chrome_driver_path)  # 指定 config 目录下，指定浏览器驱动

    driver.delete_all_cookies()  # 删除cookie

    logger.info("------------启动浏览器-----------------")
    driver.get(pro.get('login_url'))  # 从properties文件中获得dbshop后台登录页面路径

    driver.maximize_window()
    logger.info("------------启动浏览器 结束 -----------------")
    return driver
